﻿@{
    ViewBag.Title = "考勤标准";
    Layout = "~/Views/MasterPage.cshtml";
    ViewBag.FirstPage = "考勤管理";
    ViewBag.LastPage = "考勤标准";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>考勤标准</title>
    <script src="/Source/assets/js/jquery.min.js"></script>
    <script src="/Source/assets/js/amazeui.min.js"></script>
    <script src="/Source/assets/js/app.js"></script>

    <link rel="apple-touch-icon-precomposed" href="/Source/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI">
    <link rel="stylesheet" href="/Source/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="/Source/assets/css/admin.css">
    <script src="~/Source/layui/layui.all.js"></script>
    <script src="~/Source/layui/layui.js"></script>
    <link href="~/Source/layui/css/layui.css" rel="stylesheet" />
    <script>
        $(function () {
            //新增
            $("#btnAdd").click(function () {
                layer.open({
                    type: 2,
                    title: "新增信息",
                    area: ['400px', '300px'],
                    content: '/Punch/Insert'
                });
            });
            //编辑
            //启用或禁用
            $("a[name='ToggleA']").click(function () {
                var id = $(this).attr("data-id");
                var result = $(this).attr("data-value");
                layer.confirm("您确定要" + (result == 'false' ? '禁用' : '启用') + "该标准?", function () {
                    $.post("/Punch/ToggleStatus", { "Id": id, "Result": result }, function (returnData) {
                        layer.alert(returnData.Message);
                    })
                });
            });
        });
    </script>
</head>
<body>
    <div class="am-u-sm-12">
        <button type="button" class="am-btn am-btn-primary am-btn-xs" id="btnAdd">新增</button>
        <table class="am-table am-table-bd am-table-striped admin-content-table">
            <thead>
                <tr>

                    <th>上班时间</th>
                    <th>下班时间</th>
                    <th>标准</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @{
                    var list = BLL.PunchManager.QueryList();
                    if (list.Count != 0)
                    {
                        foreach (var item in list)
                        {
                    <tr>
                        <td>@item.time1</td>
                        <td>@item.time2</td>
                        <td>
                            @{
                            var punchName = string.Empty;
                            //0---上半年 
                            //1--下半年 
                            //-1---全年
                            switch (item.type)
                            {
                                case 0: punchName = "上半年"; break;
                                case 1: punchName = "下半年"; break;
                                case -1: punchName = "全年"; break;
                                default:
                                    break;
                            }
                            }
                            @punchName
                        </td>
                        <td>
                            @{
                            if (item.IsEable)
                            {
                                @:启用
                                }
                            else
                            {
                                @:禁用
                                }
                            }
                        </td>
                        <td>
                            <a data-id="@item.Id" name="ModifyA">编辑</a>
                            @{
                            if (item.IsEable)
                            {
                                @: <a data-id="@item.Id" data-value="false" name="ToggleA">禁用</a>
                             }
                            else
                            {
                                @: <a data-id="@item.Id" data-value="true" name="ToggleA">启用</a>
                             }
                            }

                        </td>
                    </tr>
                        }
                    }
                    
                }
            </tbody>
        </table>
    </div>
</body>
</html>
